package com.example.demo.dao;

import com.example.demo.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

@Repository
public class DepartmentDao {
    //0.模拟数据库中的数据
    private static Map<Integer, Department> departments = null;

    static {
        departments = new HashMap<Integer, Department>();//创建一个部门表
        //初始化表数据
        departments.put(10001, new Department(10001, "教学部"));
        departments.put(10002, new Department(10002, "市场部"));
        departments.put(10003, new Department(10003, "教研部"));
        departments.put(10004, new Department(10004, "公关部"));
        departments.put(10005, new Department(10005, "技术部"));
        departments.put(10006, new Department(10006, "总裁办"));
    }


    //1.获得所有部门信息
    public Collection<Department> getDepartments() {
        return departments.values();
    }

    //2.通过id获取部门信息
    public Department getDepartmentById(Integer id) {
        return departments.get(id);
    }
}
